package br.com.wepa.webapps.orca.controle.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionServlet;

import br.com.wepa.webapps.logger.TraceLogger;
import br.com.wepa.webapps.orca.controle.ConstantesControle;
import br.com.wepa.webapps.orca.controle.ControleWeb;
import br.com.wepa.webapps.orca.logica.persistencia.PersistenceDelegator;

/**
 * 
 * 
 * 
 * 
 */
public class OrcaServlet extends ActionServlet implements ConstantesControle {
	private static final long serialVersionUID = 1L;

	@SuppressWarnings("unused")
	private static final TraceLogger logger = new TraceLogger(
			OrcaServlet.class);

	public OrcaServlet() {
		super();
	}

	@Override
	public void init() throws ServletException {
		super.init();
	}

	/**
	 * <p>
	 * Perform the standard request processing for this request, and create the
	 * corresponding response.
	 * </p>
	 * 
	 * Onde se inicia os conversores i18n
	 * 
	 * @param request
	 *            The servlet request we are processing
	 * @param response
	 *            The servlet response we are creating
	 * 
	 * @exception IOException
	 *                if an input/output error occurs
	 * @exception ServletException
	 *                if a servlet exception is thrown
	 */
	protected void process(HttpServletRequest request,
			HttpServletResponse response) throws IOException, ServletException {
		try {
			ControleWeb.setCurrents(request, response);
			super.process(request, response);			
			PersistenceDelegator.getHibernatePersistence().closeSession();
		} catch (Exception e) {
			throw new ServletException(e);
		}
	}

}
